export default {
	data() {
		return {
shareUrl:'https://fendou.life/uploads/20230207/4f8cd2699d32510f732267b0221bb6ad.jpg',
userInfo:null
		}
	},
	
	onLoad: function() {
		this.userInfo=uni.getStorageSync('userInfo');
		this.shareUrl = this.$imageURL
		wx.showShareMenu({
			withShareTicket: true,
			menus: ["shareAppMessage", "shareTimeline"]
		})
	},
	onShareAppMessage(res) {
		this.addScores()
		let that = this;
		console.log(res,'++++',that.$scope,"转发-->");
		let imageUrl = that.shareUrl || '';
		if (res.from === 'button') {
			let item = res.target.dataset.item
			console.log(item,"utem");
		//这块需要传参，不然链接地址进去获取不到数据
			let path = `/pages/todo_item_note/index` + `?todo_item_id=` + item.id;
			
			return {
				title: item.todo_item_name,
				path: path,
				imageUrl: item.user.avatarUrl
			};
		}
		if (res.from === 'menu') {
		
			return {
				title: '我正在靠近自己的愿望...你来监督我吧!',
				path: '/pages/index/index',
				imageUrl: imageUrl
			};
		}
		
	},
	// 分享到朋友圈
	onShareTimeline(res) {
	
		console.log(res,"分享到朋友圈");
		this.addScores()
		return {
			title: '我正在靠近自己的愿望...你来监督我吧!',
			path: '/pages/index/index',
			imageUrl: this.shareUrl
		};
	},
	methods: {
	// 分享成不成功积分都加1,腾讯把回调函数关闭了,没有办法
	addScores(){
		this.$addScore(this.userInfo.id).then(res=>{
			console.log(res,"分享添加积分成功!");
			
		}).catch(err=>{
			
			console.log(err,"分享添加积分失败");
		})
	}
	}
}

